<?php
	add_action('admin_menu', 'cpx_remove_menu_pages', 999);
	function cpx_remove_menu_pages()
	{
		global $wp_roles;
		$current_user = wp_get_current_user();
		$roles = $current_user->roles;
		$role = array_shift($roles);
		$role_name = isset($wp_roles->role_names[$role]) ? $wp_roles->role_names[$role] : false;

		$role_arr_editor = array('Editor extend');
		$role_arr_author = array('Author extend');

		foreach ($role_arr_editor as $r)
		{
			if ($r == $role_name)
			{
				global $menu, $submenu;
				if (is_array($menu) && is_array($submenu))
				{
					reset($menu);
					$page = key($menu);
					while ((__('Dashboard') != $menu[$page][0]) && next($menu))
						$page = key($menu);
					if (__('Dashboard') == $menu[$page][0])
						unset($menu[$page]);
					reset($menu);
					$page = key($menu);
					while (!$current_user->has_cap($menu[$page][1]) && next($menu))
						$page = key($menu);
                    // Redirect to dashboard if go to : add new store
					if (preg_match('#wp-admin/post-new.php\?post_type=store#', $_SERVER['REQUEST_URI']))
						wp_redirect(get_option('siteurl') . '/wp-admin/index.php');
                    // Remove sub menu : add new store
					remove_submenu_page('edit.php?post_type=store', 'post-new.php?post_type=store');
				}
			}
		}
		foreach ($role_arr_author as $r)
		{
			if ($r == $role_name)
			{
                // remove store menu
				remove_menu_page('edit.php?post_type=store');
			}
		}

	}
?>